package com.example.poi.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private Connection conn;
    private String MySqlDriver;
    private String MySqlURL;
    private int DBType;

    public DBConnection() {
        conn = null;
    }

    public Connection getDBConn() {
        DBType = 1;
        switch (DBType) {
            case 1:
                return gteConnToMySQL();
            default:
                return null;
        }
    }

    public Connection gteConnToMySQL() {
        try {
            MySqlDriver = "org.gjt.mm.mysql.Driver";
            MySqlURL = "jdbc:mysql://localhost:3306/sky?useSSL=root&password=mysql123456&useUnicode=true&characterEncoding=UTF-8";
            Class.forName(MySqlDriver).newInstance();
            conn = DriverManager.getConnection(MySqlURL);
        } catch (Exception e) {
            e.printStackTrace(); // 打印异常以便调试
        }
        return conn;
    }
}
